<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    
</head>
<body>
    <select name="province" id="province">
        <option value="">-请选择省份-</option>
    </select>
    <select name="city" id="city">
        <option value="">-请选择城市-</option>
    </select>
    <select name="county" id="county">
        <option value="">-请选择区县-</option>
    </select>

    <script>
        let province = document.getElementById("province");
        let city = document.getElementById("city");
        let county = document.getElementById("county");
        let op = document.createElement("option");

        fetch("./city.json").then(function (response) {
            return response.json();
        }).then(function (data) {
            // console.log(data);
            for( let i in data){
                province.innerHTML += `<option value="${i}">${i}</option>`;
            }
            province.addEventListener("change", function(){
                city.options.length = 0;
                county.options.length = 0;
                
            })
        }).catch(function (err) {
            console.log(err);
        });

    </script>
    
</body>
</html>